home *** CD-ROM | disk | FTP | other *** search
- Path: news.uregina.ca!usenet
- From: tristan@nether.net (Tristan Psionic)
- Newsgroups: comp.lang.c
- Subject: Re: ?? How to dump text files to screen ??
- Date: 16 Mar 1996 03:53:14 GMT
- Organization: University of Regina
- Message-ID: <4iddva$aic@sue.cc.uregina.ca>
- References: <31430CE8.469E@aol2.com>
- Reply-To: tristan@nether.net (Tristan Psionic)
- NNTP-Posting-Host: dec5057.cs.uregina.ca
- X-Newsreader: IBM NewsReader/2 v1.2.5
-
- In <31430CE8.469E@aol2.com>, Neil <neil@aol2.com> writes:
- >I need help -- how can I open up a text file and just dump it
- >all out (in plain text) to the screen?
- Well, you can't do exactly that, but this is pretty close (and pretty raw):
-
- #include <stdio.h>
-
- void main (int argc,char argv[])
- {
- FILE *fp;
- char s[1000];
- if (argc >= 1)
- {
- fp=fopen(argv[1],"r");
- while (gets(s,1000,fp) != NULL)
- {
- printf("%s",s);
- }
- fclose(fp);
- }
- else
- {
- printf("usage: dumptext [filename]"
- }
- }
-
- That should work. I'm not an expert at C or anything, but I do believe that
- there aren't any hugely flawed errors in it. Good luck.
- -tristan
-
-